/**
 * @author xchen
 */
public class code_383 {
	public boolean canConstruct(String ransomNote, String magazine) {
		int ransomNoteLength = ransomNote.length();
		int magazineLength = magazine.length();
		if (magazineLength < ransomNoteLength) {
			return false;
		}
		int[] ransomCharNum = new int[26];
		int[] magazineCharNum = new int[26];
		for (int i = 0; i < ransomNoteLength; i++) {
			int charNum = ransomNote.charAt(i) - 97;
			ransomCharNum[charNum]++;
		}
		for (int i = 0; i < magazineLength; i++) {
			int charNum = magazine.charAt(i) - 97;
			magazineCharNum[charNum]++;
		}
		for (int i = 0; i < 26; i++) {
			if (magazineCharNum[i] >= ransomCharNum[i]) {
				continue;
			}
			return false;
		}
		return true;
	}
}
